<?php
session_start();
      if (isset($_SESSION['k_username'])) {
echo "<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" />";
echo "<title >Socios</title>";
?>

<link rel="stylesheet" href="/style.css" type="text/css" />
<? echo "<style type=\"text/css\">"; ?>
<!--BODY {
	background-color: #EBEBEB;
	margin-left: 20px;
	margin-top: 20px;
	margin-right: 0px;
	margin-bottom: 0px;
	font-size: 90%;
}
TD{
	font-family: Verdana, Helvetica, sans-serif;
 	font-size: 12px
}
H1 {
	font : bold 14pt  Verdana, Tahoma, sans-serif;
	text-align : left;
	margin-bottom : 0;
	margin-left : 0;
	margin-right : 0;
	margin-top : 0;
}
H1.mess {
	font : bold 14pt Verdana, Tahoma, sans-serif;
	text-align : center;
	color : red;
	margin-bottom : 0;
	margin-left : 0;
	margin-right : 0;
	margin-top : 0;
}
TR.data{
	background : #A6A6A6;
	font-family: Verdana, Helvetica, sans-serif;
 	font-size: 12px
}
TR.dataheader{
	font-family: Verdana, Helvetica, sans-serif;
	background : #808080;
	font-weight : bold;
	text-align : center;
	font-size: 12px
}
H2{
	font : bold 13px Verdana, Tahoma, sans-serif;
	text-align : center;
	margin-bottom : 0;
	margin-left : 0;
	margin-right : 0;
	margin-top : 0;
}
P {
	margin : 3;
}
A {
	font: Verdana, Tahoma, sans-serif;
	color : blue;
}
A:HOVER {
	font: Verdana, Tahoma, sans-serif;
	color : red;
	text-decoration : underline;
}
/*A:LINK {
text-decoration : none;
}
*/
A:VISITED {
	font: Verdana, Tahoma, sans-serif;
	text-decoration : none;
}
A.menu {
	font: bold 12px Verdana, Tahoma, sans-serif;
	color : #B75E0B;
	text-decoration : none;
}
A.menu:HOVER {
	font: Verdana, Tahoma, sans-serif;
	color : Navy;
}
A.menuACT {
	font: bold 12px Verdana, Tahoma, sans-serif;
	color : red;
	text-decoration : none;
}
/* FORM CLASSES */
.INPUTmy {
	border : 1px solid #000080;
	background : White;
	font-family : Courier New;
	font-size : 12px;
}
.INPUTmyERR {
	border : 1px solid Black;
	font-family : Courier New;
	font-size : 12px;
	background : #CC6633;
}
.INPUTmyACT {
	border : 1px solid #990033;
	background : #FFFFCC;
	font-family : Courier New;
	font-size : 12px;
	color : #000099;
}
.BUTTONmi {
	font-family: Verdana, Tahoma, sans-serif;
	font-size: 12px;
	color: black ;
	background-color: #EBEBEB;
	border: 1px solid Black;
	width : 50px;
}
.BUTTONmySmall {
	font-family: Verdana, Tahoma, sans-serif;
	font-size: 12px;
	color: black ;
	background-color: #CCCCCC;
	border: 1px solid Black;
}
.ERROR_HEADER{
	color: red;
	font : bold;
	text-align : center;
}
.ERROR_ELEMENT{
	color: red ;
}
/* END FORM CLASSES*/
.header {
	color : Teal;
	text-align : center;
	font : bold 13px;
}
-->
<?

echo "<!--
.Estilo1 {font-size: 24px}
-->
</style>
</head>
<body>";
 include('conexion.inc.php');
  $link = Conectarse();

mysql_select_db("gotica_ordencompras" ,$link);

?>

<div align="center" class="Estilo1">VER ORDENES</div>
<div align="center" >
<a href="/ordenes.php">Inicio</a>

</div>

<table border="0" cellspacing="2" cellpadding="2" align="center" >
<tr class="dataheader" align="center">
<td>Ver</td>
<?
if($_SESSION['grupo']==1 || $_SESSION['grupo']==3 ){
echo "<td>Rechazar</td>";}
?>
<td>Borrar</td>
<td width="80">Numero de Orden</td>
<td>Estado </td>
<td>Fecha Emision</td>
<td>Cliente</td>
<td>Proveedor</td>
<td>Solicitante</td>
<td>Gestion</td>
<td>Detalle de la Orden</td>
</tr>

<?php
$sql= "Select * FROM ordencompra";
$result = mysql_query($sql, $link);
while($row= mysql_fetch_array($result)){
echo "<form method=\"post\" action=\"verlaorden.php\" >";
echo "<tr class=\"data\"><td width=\"3%\"><input type=\"hidden\" name=\"idorden\" value=\"$row[idorden]\" /><input type=\"submit\" class=\"buttonmi\" name=\"ver\" value=\"Bajar\" /></td>";
echo "</form>";
if($_SESSION['grupo']==1 || $_SESSION['grupo']==3 ){
echo "<form method=\"post\" action=\"rechazar.php\">";
echo "<td width=\"3%\"><input type=\"hidden\" name=\"idorden\" value=\"$row[idorden]\" /><input type=\"submit\" class=\"buttonmi\" name=\"ver\" value=\"Rechazar\" /></td>";
echo "</form>";}
echo "<form method=\"post\" action=\"borraorden.php\">";
echo "<td width=\"3%\"><input type=\"hidden\" name=\"idorden\" value=\"$row[idorden]\" /><input type=\"submit\" class=\"buttonmi\" name=\"ver\" value=\"Borrar\" /></td>";
echo "</form>";
echo "<td width=\"7%\">".$row['idorden']."</td>";
$sql1= "Select * FROM estado where idestado=$row[idestado] ";
$result1 = mysql_query($sql1, $link);
$row1= mysql_fetch_array($result1);
echo "<td width=\"5%\">".$row1['estado']."</td>";
echo "<td width=\"5%\">".$row['fechapedido']."</td>";
$sql2= "Select * FROM cliente where idcliente=$row[idcliente] ";
$result2 = mysql_query($sql2, $link);
$row2= mysql_fetch_array($result2);
echo "<td width=\"5%\">".$row2['N_Cliente']."</td>";
$sql3= "Select * FROM proveedor where idproveedor=$row[idproveedor] ";
$result3 = mysql_query($sql3, $link);
$row3= mysql_fetch_array($result3);
echo "<td width=\"5%\">".$row3['N_proveedor']."</td>";
echo "<td width=\"5%\">".$row['idsolicitante']."</td>";
$sql30= "Select * FROM Gestionador where idgestionador=$row[idgestionador] ";
$result30 = mysql_query($sql30, $link);
$row30= mysql_fetch_array($result30);
echo "<td width=\"5%\">".$row30['Gestionador']."</td>";
$sql4= "Select * FROM detallepedido where idorden=$row[idorden] ";
$result4 = mysql_query($sql4, $link);
echo "<td width=\"30%\">";
while($row4= mysql_fetch_array($result4)){
$sql5= "Select * FROM producto where idproducto=$row4[idproducto] ";
$result5 = mysql_query($sql5, $link);
$row5= mysql_fetch_array($result5);
echo $row4['Q_Cantidad']." ".$row5['n_producto']."\n";}
echo "</td>";
echo"</tr>";
}
?>
</table>

</body>
</html>
<?
}else
{
	echo "<SCRIPT LANGUAGE=\"javascript\">";
echo "location.href = \"index.php\"";
echo "</SCRIPT>";
	}
?>